'use strict';
const db = uniCloud.database()
const coll1 = db.collection('all')
const coll2 = db.collection('user')
const coll3 = db.collection('userform')
const dbCmd = db.command
exports.main = async (event, context) => {
	//event为客户端上传的参数
	console.log('event : ', event)
	if (event.num==1) {
		//重置全员状态
		let res = await coll2.where({
			flag:dbCmd.eq('flag')
		}).update({
			status:0,
			suijishu:'',
			num:0
		})
		
		return res
	} else if(event.num==2){
		//重置点亮人数
		let res = await coll1.where({
			_id:'28ee4e3e609f62a518d6800e57ec5fb6'
		}).update({
			num:0
		})
		
		return res
	}else if(event.num==3){
		//设置全部人数
		let res = await coll1.where({
			_id:'28ee4e3e609f67e718d88a412559c770'
		}).update({
			num:Number(event.newnum) 
		})
		
		return res
	}else{
		let res = await coll3.where({
		  _id: dbCmd.exists(true)
		}).remove()
	}
};
